﻿<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>管理取派员</title>
		<!-- 导入jquery核心类库 -->
		<script type="text/javascript" src="../../js/jquery-1.8.3.js"></script>
		<!-- 导入easyui类库 -->
		<link rel="stylesheet" type="text/css" href="../../js/easyui/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../js/easyui/themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../js/easyui/ext/portal.css">
		<link rel="stylesheet" type="text/css" href="../../css/default.css">
		<script type="text/javascript" src="../../js/easyui/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../../js/easyui/ext/jquery.portal.js"></script>
		<script type="text/javascript" src="../../js/easyui/ext/jquery.cookie.js"></script>
		<script src="../../js/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
		<script type="text/javascript">

			$(function(){

                $("body").css({visibility:"visible"});
			    $('#grid').datagrid({
                    iconCls : 'icon-forward',
			        fit : true,
					striped : true,
					border:true,
					rownumbers:true,
					pageList:[10,20,30],
					pagination:true,
					toolbar:toolbar,
					url:'../../courier_pageQuery.action',
					idFiled:'id',
                    columns:columns,
                    singleSelect:true,
                    autoRowHeight:true

                });

                $('#addWindow').window({
                    width: 800,
                    modal: true,
                    shadow: true,
                    closed: true,
                    height: 300,
                    resizable:false
                });

                $('#save').click(function(){
                    if($('#courierForm').form('validate')){
                        $('#courierForm').submit();

					}else{
                        alert('还有项目没有填写');
					}
				});
                $("#searchBtn").click(
                    function(){
                        var entity= $("#searchForm").serializeJson();
                        $("#grid").datagrid('load',entity);
                        $("#searchWindow").window('close');
					}
				);
                $("#saveAsPdf").click(function () {
					$("#searchForm").attr("action","../../courier_saveAsPdf.action");
					$("#searchForm").submit();
                });

			});

            var columns=[[ {
                field : 'id',
                checkbox : true
            },{
                field : 'courierNum',
                title : '工号',
                width : 80,
                align : 'center'
            },{
                field : 'name',
                title : '姓名',
                width : 80,
                align : 'center'
            },{
                field : 'telephone',
                title : '电话',
                width : 80,
                align : 'center'
            },{
                field : 'pda',
                title : 'PDA号',
                width : 80,
                align : 'center'
            },{
                field : 'standard.name',
                title:'取件标准',
                width : 80,
                align : 'center',
                formatter : function(data,row,index){
                    if(row.standard != null){
                        return row.standard.name;
                    }
                    return "";
                }
            },{
                field : 'type',
                title : '取派员类型',
                width : 120,
                align : 'center'
            }, {
                field : 'company',
                title : '所属单位',
                width : 200,
                align : 'center'
            }, {
                field : 'deltag',
                title : '是否作废',
                width : 80,
                align : 'center',
                formatter:function(value,tagrow,tagindex){
                    if(value=="0"){
                        return "<img src='../../images/icon1/icon1.png'>";
                    }else{
                        return "<img src='../../images/icon1/icon2.png'>";

                    }
                }
            },{
                field : 'vehicleType',
                title : '车型',
                width : 80,
                align : 'center'
            },{
                field : 'vehicleNum',
                title : '车牌号',
                width : 80,
                align : 'center'
            }
            ]];
            var toolbar=[{
                id : 'button-add',
                text : '增加',
                iconCls : 'icon-add',
                handler : doAdd
            },{
                id : 'button-edit',
                text : '修改',
                iconCls : 'icon-add',
                handler : doEdit
            },{
                id : 'button-cancel',
                text : '作废',
                iconCls : 'icon-cancel',
                handler : doCancel
            },{
                id : 'button-restore',
                text : '还原',
                iconCls : 'icon-restore',
                handler : doRestore
            },{
                id : 'button-search',
                text : '查询',
                iconCls : 'icon-search',
                handler : doSearch
            },{
                id : 'button-search',
                text : '查询',
                iconCls : 'icon-print',
                handler : doCharts2
            },{
                id : 'button-search',
                text : '查询',
                iconCls : 'icon-print',
                handler : doCharts3
            }];

            $.fn.serializeJson = function(){
                var serializeObj={};
                var array=this.serializeArray();
                var str=this.serialize();
                $(array).each(function(){
                    if(serializeObj[this.name]){
                        if($.isArray(serializeObj[this.name])){
                            serializeObj[this.name].push(this.value);
                        }else{
                            serializeObj[this.name]=[serializeObj[this.name],this.value];
                        }
                    }else{
                        serializeObj[this.name]=this.value;
                    }
                });
                return serializeObj;
            };



            function doAdd(){

                $('#addWindow').window("open");
            }
            function doEdit(){

                var rows = $('#grid').datagrid('getSelections');

                if(rows.length>1||rows.length==0){
                    alert('只能修改一行');
                    return;
				}


				var row = rows[0];
                $('#courierForm').form('load',row);


                $('#standard').combobox(
                        'select',row.standard.id
                );

                $('#addWindow').window("open");

			}
            function doCancel(){

                var rows = $('#grid').datagrid('getSelections');


                if(rows.length==0){
                    alert('请选择一行');
                    return ;
				}

				var array =new  Array();
                for(var i=0;i<rows.length;i++){
                    array.push(rows[i].id);
                    alert(rows[i].id);
				}
				var ids = array.join(",");

				window.location.href="../../courier_delete.action?ids="+ids;
			}
            function doRestore(){
                var rows = $('#grid').datagrid('getSelections');


                if(rows.length==0){
                    alert('请选择一行');
                    return ;
                }

                var array =new  Array();
                for(var i=0;i<rows.length;i++){
                    array.push(rows[i].id);
                    alert(rows[i].id);
                }
                var ids = array.join(",");

                window.location.href="../../courier_restore.action?ids="+ids;
			}
            function doSearch(){
                $("#searchWindow").window('open');
			}

			function doCharts2(){
                location="../../pages/highcharts/column.html";
			}
            function doCharts3(){
                location="../../pages/highcharts/line.html";
            }
		</script>
	</head>

	<body class="easyui-layout" style="visibility:hidden;">
		<div region="center" border="false">
			<table id="grid"></table>
		</div>
		<div class="easyui-window" title="添加或者修改收派员" id="addWindow" collapsible="false" minimizable="false" maximizable="false" style="top:20px;left:200px">
			<div region="north" style="height:31px;overflow:hidden;" split="false" border="false">
				<div class="datagrid-toolbar">
					<a id="save" icon="icon-save" href="#" class="easyui-linkbutton" plain="true">保存</a>
				</div>
			</div>

			<div region="center" style="overflow:auto;padding:5px;" border="false">
				<form id="courierForm" action="../../courier_save.action" method="post">
					<table class="table-edit" width="80%" align="center">
						<tr class="title">
							<td colspan="4">收派员信息
                                <!--提供隐藏域 装载id -->
                                <input type="hidden" name="id" />
                            </td>
						</tr>
						<tr>
							<td>快递员工号</td>
							<td>
								<input type="text" name="courierNum" class="easyui-validatebox" required="true" />
							</td>
							<td>姓名</td>
							<td>
								<input type="text" name="name" class="easyui-validatebox" required="true" />
							</td>
						</tr>
						<tr>
							<td>手机</td>
							<td>
								<input type="text" name="telephone" class="easyui-validatebox" required="true" />
							</td>
							<td>所属单位</td>
							<td>
								<input type="text" name="company" class="easyui-validatebox" required="true" />
							</td>
						</tr>
						<tr>
							<td>快递员类型</td>
							<td>
								<input type="text" name="type" class="easyui-validatebox" required="true" />
							</td>
							<td>取派标准</td>
							<td>
								<input type="text" name="standard.id"  id="standard"
										class="easyui-combobox" 
										data-options="required:true,valueField:'id',textField:'name',
											url:'../../standard_findAll.action'"/>
							</td>
						</tr>
						<tr>
							<td>车型</td>
							<td>
								<input type="text" name="vehicleType" class="easyui-validatebox" required="true" />
							</td>
							<td>车牌号</td>
							<td>
								<input type="text" name="vehicleNum" class="easyui-validatebox" required="true" />
							</td>
						</tr>
					</table>
				</form>
			</div>
		</div>
		
		<!-- 查询快递员-->
		<div class="easyui-window" title="查询快递员窗口" closed="true" id="searchWindow" collapsible="false" minimizable="false" maximizable="false" style="width: 400px; top:40px;left:200px">
			<div style="overflow:auto;padding:5px;" border="false">
				<form id="searchForm" method="post">
					<table class="table-edit" width="80%" align="center">
						<tr class="title">
							<td colspan="2">查询条件</td>
						</tr>
						<tr>
							<td>工号</td>
							<td>
								<input type="text" name="courierNum" />
							</td>
						</tr>
						<tr>
							<td>收派标准</td>
							<td>
								<input type="text" name="standard.name" />
							</td>
						</tr>
						<tr>
							<td>所属单位</td>
							<td>
								<input type="text" name="company" />
							</td>
						</tr>
						<tr>
							<td>类型</td>
							<td>
								<input type="text" name="type" />
							</td>
						</tr>
						<tr>
							<td colspan="2"><a id="searchBtn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'">查询</a> </td>
							<td colspan="2"><a id="saveAsPdf" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-print'">导出</a> </td>
						</tr>
					</table>
				</form>
			</div>
		</div>
	</body>
</html>